
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/common/assets_utils.dart';
import 'package:fzcgx_app/network/http.dart';
import 'package:fzcgx_app/router/routes.dart';
import 'package:fzcgx_app/ui/my/factory/page/certificates_upload_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/factory_base_info_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/factory_device_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/factory_environment_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/factory_production_capacity_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/factory_quality_page.dart';
import 'package:fzcgx_app/ui/my/factory/page/select_factory_products1_page.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';

class FactoryPage extends StatefulWidget {
  FactoryPage({Key key}) : super(key: key);

  @override
  _FactoryPageState createState() => _FactoryPageState();
}

class _FactoryPageState extends State<FactoryPage> {
  Map data;
  @override
  void initState() {
    requestApi();
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '工厂资料完善',
      ),
      body: SafeArea(
          child: data == null
              ? _loadingWidget()
              : SingleChildScrollView(
                  child: Column(
                    children: <Widget>[
                      InkWell(
                        onTap: () {
                          
                          Routes.navigateTo(context, FactoryBaseInfoPage(callback: (){
                            requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '基本信息',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' *',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isbase'] == 1 ? '已上传' : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: () {
                          Routes.navigateTo(context, CertificatesUploadPage(callback: (){
                             requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '证件上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    '',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['iszhengjian'] == 1 ? '已上传' : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: () {
                          Routes.navigateTo(
                              context, SelectFactoryProducts1Page());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '工厂产品',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    '',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isgongchangchanpin'] == 1
                                        ? '已上传'
                                        : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: () {
                          Routes.navigateTo(context, FactoryDevicePage(callback: (){
                            requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '工厂设备',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isgongchangshebei'] == 1
                                        ? '已上传'
                                        : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, FactoryProductionCapacityPage(callback: (){
                            requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '产量 产能',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['ischanpinchanneng'] == 1
                                        ? '已上传'
                                        : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                         onTap: (){
                           Routes.navigateTo(context, FactoryQualityPage(callback: (){
                            requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '质量要求',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['iszhiliangyaoqiu'] == 1
                                        ? '已上传'
                                        : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                          Routes.navigateTo(context, FactoryEnvironmentPage(callback: (){
                            requestApi();
                          },));
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '工厂环境',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isgongchanghuanjing'] == 1
                                        ? '已上传'
                                        : '请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      SizedBox(
                        height: AdapterUtils.getHeight(47),
                      ),
                      Container(
                          width: AdapterUtils.screenWidth(),
                          height: AdapterUtils.getHeight(50),
                          margin: EdgeInsets.all(15),
                          child: FlatButton(
                              onPressed: () {},
                              disabledColor: Color(0xff15A1FF).withAlpha(80),
                              color: Color(0xff15A1FF),
                              shape: RoundedRectangleBorder(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(4)),
                              ),
                              child: Text(
                                '回到首页',
                                style: TextStyle(
                                  fontSize: AdapterUtils.getSp(16),
                                  color: Colors.white,
                                  fontWeight: FontWeight.w500,
                                ),
                              ))),
                    ],
                  ),
                )),
    );
  }

  Widget _loadingWidget() {
    return Center(
      child: CupertinoActivityIndicator(
        animating: true,
        radius: 20,
      ),
    );
  }

  void requestApi() {
     
    Http.instance.post('app/call/getusers_info_gc', null, onSuccess: (data) {
      if (mounted) {
        setState(() {
          this.data = data;
        });
      }
    }, onError: (error) {}, onFail: (fail) {});
  }

 
 
  
}
